package com.wy.ifly.mvp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wy.ifly.R;
import com.wy.ifly.mvp.b.GoodBean;

import java.util.List;

/**
 * Time:7/19/21
 * Author:ypf
 * Description:
 */
class ListAdapter extends BaseAdapter {

    private Context context;
    private List<GoodBean> data;

    public ListAdapter(Context context, List<GoodBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public GoodBean getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.item_mvp, null);
        ImageView iv = view.findViewById(R.id.iv);
        TextView tvName = view.findViewById(R.id.tvName);
        TextView tvStar = view.findViewById(R.id.tvStar);

        GoodBean item = getItem(i);

        iv.setImageResource(item.getImg());
        tvName.setText(item.getName());
        tvStar.setText(item.getStar());

        return view;
    }

}
